package com.rui.study.commons.study.support.factory;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class SimpleThreadFactory implements ThreadFactory {

    private String threadName;

    private AtomicInteger count = new AtomicInteger();

    public SimpleThreadFactory(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public Thread newThread(Runnable r) {
        return new Thread(r, threadName + "-" + count.getAndIncrement());
    }
}
